﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EnCor.Logging
{
    public class LoggingInitializer
    {
        public void Initlize(LoggingConfig config)
        {
            IList<ILogAppender> loggers = new List<ILogAppender>();
            LoggerFactory factory = new LoggerFactory();

            if (config.Appenders.Count == 0)
            {
                loggers.Add(new ConsoleLogAppender());
            }

            foreach (LogAppenderConfig loggerConfig in config.Appenders)
            {
                ILogAppender logger = factory.Create(null, loggerConfig);
                loggers.Add(logger);
            }

            LogManager.Setup(loggers);
        }
    }
}
